<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>

        <style>
            .active {
                color: red;
            }
            .line {
                color: blue;
            }
        </style>
    </head>
    <body>
        <div id="app" v-cloak>
            <h2 class="active">{{message}}</h2>
            <h2 :class="{active: isActive, line: isLine}">{{message}}</h2>
            <h2 :class="getClasses()">{{message}}</h2>
            <button @click="btnClick">改变颜色</button>
        </div>
        <script src="../../js/vue.js"></script>
        <script>
          const app = new Vue({
                el: '#app',
                data: {
                    message: '你好呀',
                    isActive: true,
                    isLine: false,
                },
                methods: {
                    btnClick: function () {
                        this.isActive = !this.isActive;
                        this.isLine = !this.isLine;
                    },
                    getClasses: function () {
                        return {active: this.isActive, line: this.isLine}
                    }
                }
            }) 
        </script>
    </body>
</html>